package org.example.Mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.Pojo.Emp;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {


//    /*
//    * 查询并放回所有的数据
//    * */
//    @Select("select emp.* ,dept.name as deptName from emp left join dept on emp.dept_id = dept.id limit #{page},#{size}")
//    public List<Emp> selectAll(Integer page, Integer size);


    /*
    * 查询所有的数据个数
    * */
    @Select("select count(*) from emp left join dept on emp.dept_id = dept.id;")
    public Long count();

    /*
     * 查询并放回所有的数据
     * */
    //@Select("select e.*, d.name deptName from emp as e left join dept as d on e.dept_id = d.id where e.name like concat('%',#{name},'%') and e.gender = #{gender}  and e.entry_date between #{begin} and #{end}")
    public List<Emp> selectAll(String name, Integer gender, LocalDate begin, LocalDate end);


    /*
    * 添加员工的基本信息
    * */
    public void add(Emp emp);

    /*
     * 删除员工通过id数组
     * */
    public void delete(Integer id);

    /*
    * 获取员工的基本信息
    * */
    public Emp getById(Integer id);

    /*
    * 添加员工的基本信息包括Id
    * */
    public void addId(Emp emp);

    /*
    * 更新员工的信息
    * */
    public void update(Emp emp);


    /*
    * 获取全部员工
    * */
    public List<Emp> getAllEmp();


    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp selectByUserNameAndPassword(String username, String password);
}
